function formatTime(time) {
	if (typeof time !== 'number' || time < 0) {
		return time
	}

	var hour = parseInt(time / 3600)
	time = time % 3600
	var minute = parseInt(time / 60)
	time = time % 60
	var second = time

	return ([hour, minute, second]).map(function(n) {
		n = n.toString()
		return n[1] ? n : '0' + n
	}).join(':')
}

function getNewTime(date) {
	var year = date.getFullYear()
	var month = date.getMonth() + 1
	var day = date.getDate()
	var hour = date.getHours()
	var minute = date.getMinutes()
	var second = date.getSeconds()
	return year + "-" + month + "-" + day + "- " + hour + ":" + minute + ":" + second + ":";
}

function getTime(faultDate, completeTime) {
	var dataBegin = new Date(faultDate);
	var dataEnd = new Date(completeTime);
	var time = (dataEnd - dataBegin) / 1000;
	if (null != time && "" != time) {
		if (time > 60 && time < 60 * 60) {
			time = parseInt(time / 60.0) + "分钟" + parseInt((parseFloat(time / 60.0) -
				parseInt(time / 60.0)) * 60) + "秒";
		} else if (time >= 60 * 60 && time < 60 * 60 * 24) {
			time = parseInt(time / 3600.0) + "小时" + parseInt((parseFloat(time / 3600.0) -
					parseInt(time / 3600.0)) * 60) + "分钟" +
				parseInt((parseFloat((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60) -
					parseInt((parseFloat(time / 3600.0) - parseInt(time / 3600.0)) * 60)) * 60) + "秒";
		} else {
			time = parseInt(time) + "秒";
		}
	} else {
		time = "0 时 0 分0 秒";
	}
	return time;
},

module.exports = {
	formatTime: formatTime,
	getNewTime: getNewTime,


}
